package p270jp.pxv.android.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import androidx.databinding.DataBindingUtil;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import java.util.Objects;
import p019aj.MultipleRoundedCornersTransformation;
import p090d0.C2518n;
import p144f1.C3017s;
import p172g5.Transformation;
import p184gi.AnalyticsParameter;
import p270jp.pxv.android.R;
import p270jp.pxv.android.legacy.model.PixivNovel;
import p274k2.ContextCompat;
import p314lg.ViewRankingCarouselNovelItemBinding;
import p325m0.MutabilityOwnership;
import p330m5.GlideUrl;
import p374nm.BaseMuteLayout;
import p410p5.FitCenter;
import p460r5.DrawableTransitionOptions;
import p470ri.HashtagService;
import p677zi.PixivImageLoader;

/* renamed from: jp.pxv.android.view.RankingCarouselNovelItemView */
/* loaded from: classes2.dex */
public class RankingCarouselNovelItemView extends BaseMuteLayout {

    /* renamed from: b */
    public ViewRankingCarouselNovelItemBinding f19656b;

    /* renamed from: c */
    public final HashtagService f19657c = (HashtagService) C2518n.m7641d(HashtagService.class);

    /* renamed from: d */
    public final PixivImageLoader f19658d = (PixivImageLoader) C2518n.m7641d(PixivImageLoader.class);

    public RankingCarouselNovelItemView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    @Override // p374nm.BaseMuteLayout
    /* renamed from: a */
    public View mo3337a() {
        ViewRankingCarouselNovelItemBinding bbVar = (ViewRankingCarouselNovelItemBinding) DataBindingUtil.m11370c(LayoutInflater.from(getContext()), R.layout.view_ranking_carousel_novel_item, this, false);
        this.f19656b = bbVar;
        return bbVar.f2666e;
    }

    public void setAnalyticsParameter(AnalyticsParameter cVar) {
        this.f19656b.f21363r.setAnalyticsParameter(cVar);
    }

    public void setNovel(PixivNovel pixivNovel) {
        if (C3017s.m6470f(pixivNovel, false)) {
            setMuteCoverVisibility(0);
            return;
        }
        setMuteCoverVisibility(8);
        PixivImageLoader aVar = this.f19658d;
        Context context = getContext();
        String medium = pixivNovel.imageUrls.getMedium();
        ImageView imageView = this.f19656b.f21362q;
        Objects.requireNonNull(aVar);
        MutabilityOwnership.m3745m(context, "context");
        MutabilityOwnership.m3745m(imageView, "imageView");
        if (medium == null || medium.length() == 0) {
            imageView.setImageResource(R.drawable.shape_bg_illust);
        } else if (aVar.m64b(context)) {
            MultipleRoundedCornersTransformation aVar2 = new MultipleRoundedCornersTransformation((int) context.getResources().getDimension(R.dimen.rounded_view_radius), 0, 15);
            RequestBuilder<Drawable> o = Glide.m9615e(context).mo1132o(new GlideUrl(medium, aVar.f31482a));
            Transformation<Bitmap>[] lVarArr = {new FitCenter(), aVar2};
            Object obj = ContextCompat.f19963a;
            Drawable b = ContextCompat.C4472c.m4259b(context, R.drawable.shape_bg_illust_rounded);
            Objects.requireNonNull(b, "null cannot be cast to non-null type android.graphics.drawable.GradientDrawable");
            o.mo472C(lVarArr).mo452s((GradientDrawable) b).mo1139S(DrawableTransitionOptions.m2637b()).m9609L(imageView);
        }
        this.f19656b.f21366u.setText(pixivNovel.title);
        this.f19656b.f21365t.setText(getContext().getResources().getString(R.string.novel_words_format, Integer.valueOf(pixivNovel.textLength)));
        this.f19656b.f21364s.setText(this.f19657c.m2578c(pixivNovel));
        this.f19656b.f21363r.setWork(pixivNovel);
        this.f19658d.m60f(getContext(), pixivNovel.user.profileImageUrls.getMedium(), this.f19656b.f21368w);
        this.f19656b.f21367v.setText(pixivNovel.user.name);
    }
}
